#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
//mpicc -std=c99 -o cmake-build/mpi/test5 mpi/test5.c && mpirun -np 4 ./cmake-build/mpi/test5
int main(int argc,char*argv[])
{
    int rank,value=1;
    MPI_Init(&argc,&argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
    while(value>0)
    {
        if(0==rank)
        {
            printf("Please input a positive value: 0 to exit\n");
            fflush(stdout);
            scanf("%d",&value);
        }
        MPI_Bcast(&value,1,MPI_INT,0,MPI_COMM_WORLD);
        printf("Process %d got value %d\n",rank,value);
        fflush(stdout);
    }
    MPI_Finalize();
    return 0;
}
